package com.jjh.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jjh.search.SearchManager;

public class SearchController extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		doPost(req, resp);
		
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		String searchWord = req.getParameter("searchWord").trim();
		
		SearchManager searchManager = new SearchManager(searchWord);
		
		List searchList = null;
		searchList = searchManager.search();
		
		RequestDispatcher dispatcher = req.getRequestDispatcher("search.jsp");
		req.setAttribute("searchResult", searchList);
		dispatcher.forward(req, resp);
	}

	
	
}
